package com.micromsg.basic.web.controller;

import com.micromsg.basic.web.task.AsyncTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class RestIndexController {
    // 127.0.0.1:9001/api/index
    // 127.0.0.1:9001/api/hello

    @Autowired
    private AsyncTask asyncTask;

    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public Object index() throws Exception {
        return "index";
    }

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public Object hello() throws Exception {
        return "hello";
    }

    @RequestMapping(value = "/async", method = RequestMethod.GET)
    public Object async() throws Exception {
        asyncTask.processRequest("api/async");
        return "index";
    }
}
